import {createRouter,createWebHistory} from 'vue-router'
import Layout from '@/layout/index.vue'

// 固定路由
export const constantRoutes = [
	{
		path: '/login',
		name: 'Login',
		hidden:true,
		component: () => import('@/views/login/LoginView.vue'),
		meta: {
			title: '登录页面'
		}
	},
	{
		path: '/',
		component: Layout,
		name:'index',
		redirect: '/dashboard',
		meta: {
			title: '后台首页',
			icon: 'Odometer',
			roles: ['admin', 'user:*']
		},
		children: [{
			path: '/dashboard',
			component: () => import('@/views/dashboard/index.vue'),
			name: 'Dashboard',
			hidden:true,
			meta: {
				title: '欢迎页',
				icon: 'Mic',
				roles: ['admin', 'user:*']
			}
		}]
	},
	{
		path: '/404',
		component: () => import('@/views/errorpage/404.vue'),
		hidden: true
	},
	{
		path: '/401',
		component: () => import('@/views/errorpage/401.vue'),
		hidden: true
	},
]

//异步路由

const router = createRouter({
	routes: constantRoutes,
	history: createWebHistory(),
	scrollBehavior() {
		return {
			left: 0,
			top: 0,
		}
	},
})


export default router